package com.blogobject.login.service;

import com.blogobject.login.domain.Admin;
import com.blogobject.login.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;

public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin loginQueryName(Admin admin) {
        Admin admin1 = adminMapper.loginQueryName(admin.getUsername());
        if (admin1!=null){
            if(admin1.getPassword().equals(admin.getPassword())){
                return admin1;
            }else {
                try {
                    throw new Exception("密码输入错误！请输入正确的密码！");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }else {
            try {
                throw new Exception("此用户不存在！请输入正确的账号或跳转注册！");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return null;
    }
}
